const {contextBridge, ipcRenderer} = require('electron')
// 嵌入的三方网页与主进程通信
contextBridge.exposeInMainWorld('embeddedPageEvent', {
    onPreviewData: (callback) => ipcRenderer.on('previewData', callback),
    returnExtractData: (dataList) => ipcRenderer.sendToHost('returnExtractData', dataList),

    returnExtraData: (type, d) => ipcRenderer.sendToHost('returnExtraData', type, d),

    selectStatus: (allowPreSelect, selected, preSelect, selectedXpath) => ipcRenderer.sendToHost('selectStatus', allowPreSelect, selected, preSelect, selectedXpath),

    onSelectAll: (callback) => ipcRenderer.on('selectAll', callback),

    onCancelSelect: (callback) => ipcRenderer.on('cancelSelect', callback),


    onTestXpath: (callback) => ipcRenderer.on('testXpath', callback),


    onSelectScene: (callback) => ipcRenderer.on('selectScene', callback),
    returnSelectXpath: (xpath) => ipcRenderer.sendToHost('returnSelectXpath', xpath),

    onNeedExtraData: (callback) => ipcRenderer.on('needExtraData', callback),

})


console.log('embedded_page_preload script loaded!');
